package cn.hwh.springframework.beans.factory.support;

import cn.hwh.springframework.beans.factory.config.BeanDefinition;

/**
 * @author wenhao hu
 * @title: AbstractAutowireCapableBeanFactory
 * @projectName mini-spring
 * @description: TODO
 * @date 2022/1/2411:47
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{

    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) {
        Object bean ;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
            throw new RuntimeException("Bean暂未创建！");
        }
        addSingleton(beanName,bean);
        return bean;
    }
}
